package br.gov.ibama.client.componentes;

import java.util.ArrayList;
import java.util.List;

import br.gov.ibama.client.servico.ServicoOperacoesCRUD;

import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;

public class FormularioBasis extends DynamicForm {

	private ServicoOperacoesCRUD servico;

	private List<SecaoBasis> secoes;
	private List<FormItem> itens;

	public FormularioBasis() {
		configuraFormulario();
	}

	public void configuraFormulario() {
		this.secoes = new ArrayList<SecaoBasis>();
		this.itens = new ArrayList<FormItem>();
		setWidth100();
		setPadding(0);
		setCanDragResize(true);
		setShowTitlesWithErrorMessages(true);
		setShowErrorIcons(true);
		setSectionVisibilityMode(VisibilityMode.MUTEX);

	}

	public void adicionarCampos(FormItem... fields) {
		setFields(fields);
	}

	public List<SecaoBasis> getSecoes() {
		return secoes;
	}

	public void setSecoes(List<SecaoBasis> secoes) {
		this.secoes = secoes;
	}

	public List<FormItem> getItens() {
		return itens;
	}

	public void setItens(List<FormItem> itens) {
		this.itens = itens;
	}

	public void fetchData(String name, int id) {
		this.servico.fetch(name, id);
	}

	public void apaga(String name, int id) {
		this.servico.apaga(name, id);
	}

	public ServicoOperacoesCRUD getServico() {
		return servico;
	}

	public void setServico(ServicoOperacoesCRUD servico) {
		this.servico = servico;
	}
	
	
}
